package top.lingkang.finalsession.solon;

import org.noear.solon.Solon;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author lingkang
 * @create by 2024/5/9 17:18
 */
public class FinalSessionPlugin implements Plugin {
    private static final Logger log = LoggerFactory.getLogger(FinalSessionPlugin.class);

    @Override
    public void start(AppContext context) throws Throwable {
        if (Solon.app().enableSessionState() == false
                || Solon.app().chainManager().getSessionStateFactory().priority() > 0) {
            return;
        }
        // 注册bean
        context.beanScan(FinalSessionFilter.class);
        Solon.app().chainManager().setSessionStateFactory(new FinalSessionSolonFactory(context));
        log.info("final-session-solon plugin load success");

    }
}
